import { ref } from 'vue'
import type { Position } from '../types/chess'

export function useChessAI() {
  const difficulty = ref<'easy' | 'medium' | 'hard'>('medium')
  
  const findBestMove = (
    board: (string | null)[][],
    validMoves: Position[],
    color: 'white' | 'black',
    calculateValidMoves: (row: number, col: number) => Position[]
  ): Position | null => {
    // 简单实现：随机选择一个有效移动
    if (!validMoves || validMoves.length === 0) return null
    
    // 随机选择一个有效移动
    const randomIndex = Math.floor(Math.random() * validMoves.length)
    return validMoves[randomIndex]
  }

  const setDifficulty = (level: 'easy' | 'medium' | 'hard') => {
    difficulty.value = level
  }

  return {
    difficulty,
    findBestMove,
    setDifficulty
  }
} 